package com.yc.snacknet_vue.bean;

import java.io.Serializable;

import com.yc.snacknet_vue.utils.StringUtil;

/**
 * 购物车实体类   多表数据
 * company 源辰信息
 * @author 38929
 * @date 2021年8月6日
 * @version 1.0
 * Email 1198865589@qq.com
 */
public class CartInfo implements Serializable{

	private static final long serialVersionUID = -1218906366457375360L;
	private String cno;//UUID
	private Integer mno;//会员编号   外键  会员表
	private Integer gno;//商品编号   外键  商品表
	private Integer num;//商品数量
	
	private String gname;//商品名称
	private double price;//价格
	private String pics;//图片
	private String unit;//单位
	private String weight;//净重
	
	@Override
	public String toString() {
		return "CartBean [cno=" + cno + ", mno=" + mno + ", gno=" + gno + ", num=" + num + ", gname=" + gname
				+ ", price=" + price + ", pics=" + pics + ", unit=" + unit + ", weight=" + weight + "]";
	}
	public String getCno() {
		return cno;
	}
	public void setCno(String cno) {
		this.cno = cno;
	}
	public Integer getMno() {
		return mno;
	}
	public void setMno(Integer mno) {
		this.mno = mno;
	}
	public Integer getGno() {
		return gno;
	}
	public void setGno(Integer gno) {
		this.gno = gno;
	}
	public Integer getNum() {
		return num;
	}
	public void setNum(Integer num) {
		this.num = num;
	}
	public String getGname() {
		return gname;
	}
	public void setGname(String gname) {
		this.gname = gname;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public String getPics() {
		return pics;
	}
	public void setPics(String pics) {
		//此时pic查询的数据库中pics字段的值  利用别名机制
		if(StringUtil.checkNull(pics)) {
			this.pics = pics;
			return;
		}
		String [] pic = null;
		if(pics.contains(",")) {//包含,
			pic = pics.split(",");
		}else if(pics.contains(";")) {//包含;
			pic = pics.split(";");
		}else {
			pic = new String[1];
			pic[0] = pics;
		}
 		this.pics = pic[0]; //多张图时只取第一张
	}
	public String getUnit() {
		return unit;
	}
	public void setUnit(String unit) {
		this.unit = unit;
	}
	public String getWeight() {
		return weight;
	}
	public void setWeight(String weight) {
		this.weight = weight;
	}
	
	public CartInfo() {
		super();
	}
	public CartInfo(String cno, int mno, int gno, int num, String gname, double price, String pics, String unit,
			String weight) {
		super();
		this.cno = cno;
		this.mno = mno;
		this.gno = gno;
		this.num = num;
		this.gname = gname;
		this.price = price;
		this.pics = pics;
		this.unit = unit;
		this.weight = weight;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((cno == null) ? 0 : cno.hashCode());
		result = prime * result + ((gname == null) ? 0 : gname.hashCode());
		result = prime * result + gno;
		result = prime * result + mno;
		result = prime * result + num;
		result = prime * result + ((pics == null) ? 0 : pics.hashCode());
		long temp;
		temp = Double.doubleToLongBits(price);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + ((unit == null) ? 0 : unit.hashCode());
		result = prime * result + ((weight == null) ? 0 : weight.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CartInfo other = (CartInfo) obj;
		if (cno == null) {
			if (other.cno != null)
				return false;
		} else if (!cno.equals(other.cno))
			return false;
		if (gname == null) {
			if (other.gname != null)
				return false;
		} else if (!gname.equals(other.gname))
			return false;
		if (gno != other.gno)
			return false;
		if (mno != other.mno)
			return false;
		if (num != other.num)
			return false;
		if (pics == null) {
			if (other.pics != null)
				return false;
		} else if (!pics.equals(other.pics))
			return false;
		if (Double.doubleToLongBits(price) != Double.doubleToLongBits(other.price))
			return false;
		if (unit == null) {
			if (other.unit != null)
				return false;
		} else if (!unit.equals(other.unit))
			return false;
		if (weight == null) {
			if (other.weight != null)
				return false;
		} else if (!weight.equals(other.weight))
			return false;
		return true;
	}
}
